package com.henushang.ranking.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.henushang.ranking.util.mongo.MongoUtil;
import com.mongodb.client.MongoCollection;

@Repository("rankingDataDao")
public class RankingDataDaoImpl extends BaseRankingDataDaoImpl {

    private static MongoCollection coll = null;

    @Override
    public String getCollectionName() {
        return "ranking_data";
    }

    @Override
    public MongoCollection getColl() {
        if (coll == null) {
            try {
                coll = MongoUtil.getColl(getCollectionName());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return coll;
    }

    public static void main(String[] args) {
        Map<String, Object> query = new HashMap<>(1);
        query.put("category_id", "45b4a46c-7063-11e8-8232-186590d56285");
        System.out.println(new RankingDataDaoImpl().findList(query).size());
    }
}
